import { ref } from "vue";

export default function(form: any){
    const newTag = ref('')
    // 添加标签逻辑
    const handleAddTag = () => {
        const tag = newTag.value.trim()
        if (!tag) return
        
        // 检查是否已存在
        if (!form.tags.includes(tag)) {
        form.tags.push(tag)
        }
        
        newTag.value = ''
    }
    
    // 删除标签逻辑
    const removeTag = (index: number) => {
        form.tags.splice(index, 1)
    }
    return {
        newTag, 
        handleAddTag,
        removeTag
    }
}